package the.workshop.bu.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.wisteria.framework.web.APIResult;
import the.workshop.bu.dto.CustomerInfoDTO;
import the.workshop.bu.dto.req.CustomerInfoModifyReq;
import the.workshop.bu.service.ICustomerInfoService;

import javax.annotation.Resource;

@Api("客户公司资料")
@RestController
@RequestMapping("/bu/customer/info")
public class CustomerInfoController {

    @Resource
    private ICustomerInfoService customerInfoService;

    @ApiOperation("查看")
    @GetMapping("/{customerId}")
    public APIResult<CustomerInfoDTO> customerInfo(@PathVariable("customerId") Integer customerId) {
        return APIResult.success(customerInfoService.detailById(customerId));
    }

    @ApiOperation("更新")
    @PostMapping("/modify")
    public APIResult modifyCustomerInfo(@ModelAttribute CustomerInfoModifyReq req) {
        customerInfoService.updateById(req.toCustomerInfoModifyDTO());
        return APIResult.success();
    }
}
